package o;

import android.app.Activity;
import android.content.Context;
import android.os.AsyncTask;
import android.text.TextUtils;
import android.view.View;
import android.webkit.WebView;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appgallery.serverreqkit.api.bean.startup.StartupResponse;
import com.huawei.appgallery.serverreqkit.api.listener.IServerCallBack;
import com.huawei.hwCloudJs.JsClientApi;
import java.util.HashMap;
import java.util.Map;
import o.bbe.d;

public class bbc implements bah, azu {
    private static Map<azp, Class<? extends bbj>> ˊ = new HashMap();
    private String ʻ = null;
    private bab ʻॱ;
    private azo ʼ = null;
    private Map<String, String> ʽ;
    private azp ˊॱ = null;
    private WebView ˋ = null;
    private String ˋॱ = null;
    private boolean ˎ = true;
    private boolean ˏ = true;
    private azt ˏॱ = null;
    private boolean ͺ = false;
    private Context ॱ = null;
    private bal ॱˊ = null;
    private String ॱॱ;
    private bbj ॱᐝ;
    private String ᐝ;
    private String ᐝॱ = null;

    public class e extends AsyncTask {
        private azv ˊ;
        private View ˋ;
        private String ˎ;
        private bbe ˏ;
        final /* synthetic */ bbc ॱ;

        public e(bbc o_bbc, azv o_azv, String str, View view, bbe o_bbe) {
            this.ॱ = o_bbc;
            this.ˎ = str;
            this.ˊ = o_azv;
            this.ˋ = view;
            this.ˏ = o_bbe;
        }

        protected Object doInBackground(Object[] objArr) {
            return new bai().ॱ(this.ˎ);
        }

        protected void onPostExecute(Object obj) {
            if ((obj instanceof bal) && (this.ॱ.ॱ instanceof Activity)) {
                this.ॱ.ॱˊ = (bal) obj;
                this.ॱ.ॱˊ.ˎ(this.ˋ);
                this.ॱ.ॱˊ.ˎ(this.ˊ, this.ˏ);
            }
        }
    }

    public bbc() {
        if (ˊ.size() == 0) {
            ॱ(azp.INTERNAL, bbg.class);
            ॱ(azp.EXTRA, bbk.class);
            ॱ(azp.H5GAME, bbh.class);
            ॱ(azp.EXPLOR, bbi.class);
        }
    }

    private static void ॱ(azp o_azp, Class<? extends bbj> cls) {
        ˊ.put(o_azp, cls);
    }

    public void ˊ(Context context, WebView webView, String str, Map<String, String> map, String str2) {
        this.ॱ = context;
        this.ˋ = webView;
        this.ʻ = str;
        this.ʽ = map;
        this.ᐝ = str2;
        if (this.ॱॱ == null) {
            this.ॱॱ = str;
        }
        if (TextUtils.isEmpty(HcridSession.ˋ().ˊ())) {
            azh.ˏ.ˏ("WebViewLoadPolicyImpl", "loadPage sign null, callStartRequest");
            ˋ();
            return;
        }
        azp ॱ = bbd.ॱ(str);
        azh.ˏ.ˋ("WebViewLoadPolicyImpl", "loadPage,matchWebViewType " + ॱ);
        if (ॱ != null && azp.NOINLIST != ॱ) {
            ˎ(ॱ);
        } else if (this.ˏ && this.ˎ) {
            azh.ˏ.ˏ("WebViewLoadPolicyImpl", "firstLoad not in whitelist:" + enx.ॱ(str));
            ˋ((azu) this);
        } else {
            azh.ˏ.ˏ("WebViewLoadPolicyImpl", "not in whitelist:" + enx.ॱ(str));
            this.ʼ.ˎ(str);
        }
    }

    private void ˋ() {
        cfw.ˎ(cvv.ˎ(), new IServerCallBack(this) {
            final /* synthetic */ bbc ˊ;

            {
                this.ˊ = r1;
            }

            public void prePostResult(BaseRequest o_cvu, ResponseBean responseBean) {
            }

            public void notifyResult(BaseRequest o_cvu, ResponseBean responseBean) {
                boolean z;
                int responseCode = responseBean.getResponseCode();
                if ((responseBean instanceof StartupResponse) && responseBean.getResponseCode() == 0 && responseBean.getRtnCode_() == 0 && ((StartupResponse) responseBean).ˊ() == 1) {
                    ((StartupResponse) responseBean).ॱˎ();
                    z = true;
                } else {
                    z = false;
                }
                this.ˊ.ˋ(z, responseCode);
            }
        });
    }

    private void ˋ(boolean z, int i) {
        if (z) {
            azh.ˏ.ˋ("WebViewLoadPolicyImpl", "sign success");
            this.ʼ.ॱ(this.ʻ);
            return;
        }
        azh.ˏ.ˏ("WebViewLoadPolicyImpl", "sign failed,resCode:" + i);
        if (i == 3) {
            this.ʼ.ˊ(-2);
        } else {
            this.ʼ.ˊ(-1);
        }
    }

    private void ˎ(azp o_azp) {
        try {
            bbj o_bbj = (bbj) ((Class) ˊ.get(o_azp)).newInstance();
            o_bbj.ॱ(o_azp);
            o_bbj.ˊ(this.ˊॱ);
            o_bbj.ˏ(this.ᐝॱ);
            o_bbj.ˎ(this.ˏॱ);
            o_bbj.ˏ(this.ͺ);
            o_bbj.ˋ(this.ʽ);
            o_bbj.ˋ(this.ॱॱ);
            o_bbj.ˏ(this.ʻॱ);
            o_bbj.ˎ(this.ᐝ);
            o_bbj.ॱ(this.ʼ);
            if (this.ˊॱ == null) {
                this.ˊॱ = o_azp;
                this.ॱᐝ = o_bbj;
            }
            if (this.ˎ) {
                this.ˋॱ = o_bbj.ˋ(this.ॱ, this.ˋ);
                this.ʼ.ˋ(this.ˋॱ);
                this.ʼ.ˎ(o_bbj.ˏ(this.ॱ, this.ˋ));
            }
            o_bbj.ˏ(this.ॱ, this.ˋ, this.ʻ, this.ˎ);
            this.ˎ = false;
            if (ˎ()) {
                ˋ(null);
            }
        } catch (Exception e) {
            azh.ˏ.ˏ("WebViewLoadPolicyImpl", "actionClass newInstance() error");
        }
    }

    public void ˎ(azo o_azo) {
        this.ʼ = o_azo;
    }

    private void ˋ(azu o_azu) {
        if (doo.ˊ(this.ॱ)) {
            new bbf(o_azu).ˏ();
        } else {
            this.ʼ.ˊ(-2);
        }
    }

    public void ˊ(boolean z, int i) {
        if (z) {
            azh.ˏ.ˋ("WebViewLoadPolicyImpl", "onDomainListUpgrade success");
            this.ˏ = false;
            this.ʼ.ॱ(this.ʻ);
            return;
        }
        azh.ˏ.ˏ("WebViewLoadPolicyImpl", "onDomainListUpgrade failed,resCode:" + i);
        if (i == 3) {
            this.ʼ.ˊ(-2);
        } else {
            this.ʼ.ˊ(-1);
        }
    }

    private boolean ˎ() {
        return System.currentTimeMillis() - bbb.ॱ() > 10800000;
    }

    public void ˋ(Context context, final View view, final bbe o_bbe) {
        if (this.ʻ != null && this.ˋ != null && view != null && o_bbe != null) {
            String ˏ;
            d ʻ = o_bbe.ʻ();
            if (ʻ != null) {
                ˏ = ʻ.ˏ();
            } else {
                ˏ = null;
            }
            if (!dof.ॱ(ˏ)) {
                final azv ˏ2 = aze.ˏ();
                if (ˏ2 != null) {
                    ˏ2.ˎ(ʻ.ˏ(), new azs(this) {
                        final /* synthetic */ bbc ॱ;

                        public void ˏ() {
                            this.ॱ.ˏ(ˏ2, view, o_bbe);
                        }
                    });
                    return;
                }
            }
            ˏ(null, view, o_bbe);
        }
    }

    private void ˏ(azv o_azv, View view, bbe o_bbe) {
        if (this.ॱˊ == null || !o_bbe.ॱ().equals(this.ॱˊ.ˎ())) {
            new e(this, o_azv, o_bbe.ॱ(), view, o_bbe).executeOnExecutor(eps.ˋ, new Object[]{o_bbe.ॱ()});
            return;
        }
        this.ॱˊ.ˎ(view);
        this.ॱˊ.ˎ(o_azv, o_bbe);
    }

    public void ˊ(azt o_azt) {
        this.ˏॱ = o_azt;
    }

    public void ˊ(boolean z) {
        this.ͺ = z;
    }

    public void ˎ(Context context) {
        if (!dof.ˋ(this.ˋॱ)) {
            JsClientApi.destroyApi(this.ˋॱ);
        }
    }

    public void ˋ(String str) {
        this.ᐝॱ = str;
    }

    public boolean ˎ(Context context, WebView webView, String str) {
        if (this.ॱᐝ != null) {
            return this.ॱᐝ.ˊ(context, webView, str);
        }
        azh.ˏ.ˏ("WebViewLoadPolicyImpl", "webViewLoadAction null , should not override loading.");
        return false;
    }

    public void ˎ(WebView webView) {
        if (this.ॱᐝ != null) {
            this.ॱᐝ.ˊ(webView);
        }
    }

    public void ˏ(bab o_bab) {
        this.ʻॱ = o_bab;
    }

    public boolean ˏ(Context context) {
        if (this.ॱᐝ != null) {
            return this.ॱᐝ.ˊ(context);
        }
        return false;
    }

    public void ˋ(String str, String str2) {
        if (this.ॱᐝ != null) {
            this.ॱᐝ.ॱ(this.ˋ, str, str2);
        }
    }
}
